import * as api from '../../service/api'

const state = {
  	bussinesslist : [],
}

const getters = {
	bussinesslist : state => state.bussinesslist,
}

const actions = {
	async getBussinessList ({ commit }, para) {
		let res = await api.bussinessList();
		console.log(res);
		if(res.errcode === 0){
			commit('setBussinessList', res.data);
		}
	},

	async updateBussiness ({ commit }, para) {
		let res = await api.updateBussiness(
			para.id,
			para.name,
			para.mobile,
			para.open_time,
			para.address,
			para.content,
			para.img
		);
		console.log(res);
		if(res.errcode === 0){
			if(para.cb){
				para.cb(res.data);
			}
		}
	},

}

const mutations = {
	setBussinessList (state, obj) {
        state.bussinesslist = obj;
    },
}

export default {
  state,
  getters,
  actions,
  mutations
}
